package pl.puntin.punclient.messages;

public final class RoomListMessage extends Message
{
	public String[] roomList;
	public String[] roomPlayers;
	
	@Override
	public byte getType() {
		return MessageTypes.S_ROOM_LIST;
	}
	
	@Override
	protected void yourDataIsReadyInitYourSelf(final byte[] data)
	{
		int i = 1;
		int roomCount = 0;
		
		while(data[i] != 0)
		{
			i+=3;
			roomCount++;
		}
		
		roomList = new String[roomCount];
		roomPlayers = new String[roomCount];
		
		for(i = 0; i < roomCount ; ++i)
		{
			roomList[i] = new String(data, 1+(3*i), 1);
			roomPlayers[i] = (new String(data, 1+(3*i)+1, 1)+" "
					+((data[1+(3*i)+2] == 48)?"New game":"Game in run ..."));
		}
	}

}
